<?php

namespace Modules\Api\Http\Controllers;

use HiCommon\Service\AreasService;
use HiCommon\Service\BaiduService;
use Illuminate\Http\Request;
use Modules\Api\Service\PublicService;
use HiCommon\Service\PublicService as HiCommonPublicService;


class PublicController extends BaseController
{

    /*省市数据-全部*/
    public function all_province_and_city(){
        $result = AreasService::api_province_and_city();

        return $result;

    }


    /**
     * 获取快递公司列表
     */
    public function get_express_list()
    {
        $list = \Modules\Web\Service\PublicService::get_express_list();
        return response_json($list);
    }

    /**
     * 物流追踪
     * 2019 11 27
     */
    public function logistics_tracking(Request $request)
    {
        $order_id = intval($request->get('order_id', 0));
        $type = intval($request->get('type', 0));

        $res = PublicService::logistics_tracking($order_id, $type);

        return response_json($res);
    }

    /**
     * 识别机动车行驶证图片转文字
     *
     * @return array
     * @author wumengmeng <wu_mengmeng@foxmail.com>
     */
    public function vehicle_license_orc()
    {
        $s_img = \Illuminate\Support\Facades\Request::input('img');
        $res = BaiduService::orc_vehicle_license($s_img);
        return $res;
    }

    /**
     * 获取取消订单，申请退款原因(标签)
     */
    public function cancel_order_label(Request $request)
    {
        $type = intval($request->get('type', 0));

        $res = PublicService::cancel_order_label($type);

        return response_json($res);
    }

    /**
     *  计算订单的优惠价格
     *  hinq 2019 11 16
     *  $arr_input['order_amount']  订单的总价格
     *  $arr_input['type']          类型   1： 优惠券  2：活动
     *  $arr_input['coupon_id']     优惠券id
     *  $arr_input['activity_id']   活动id
     **/
    public function order_imputed_price( Request $request ){
        $arr_input = (array) $request->all();
        $arr_list = HiCommonPublicService::order_imputed_price( (array) $arr_input );
        return response_json( $arr_list );
    }


}